﻿<?php
/**  
* Validator.php
*
* 김호의 php5 web programming #영진닷컴 p.554 ~ 559
*/

class Validator
{
   private $errorMsg, $validatorObject;

   public function __construct($validatorObject)
   {
      $this->validatorObject = $validatorObject;
   }

   public function validate()
   {
      return $this->validatorObject->validate();
   }

   public function is_valid()
   {
      $msg =  $this->validate();

      if(isset($msg)) 
      {
         $this->setError($msg);
         return false;
      }
      else 
      {
         return true;
      }  
   }

   public function setError($msg)
   {
      $this->errorMsg = $msg;
   }

   public function getError() 
   {
      return $this->errorMsg;
   }

}
?>
